package org.cloudnote.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.cloudnote.bean.Note;
import org.cloudnote.bean.Share;

import java.util.List;


public interface ShareMapper {
    @Select("select * from cn_share where cn_note_id=#{noteId}")
    @ResultMap("shareResultMapper")
    public Share getShareByNoteId(String noteId);

    @Insert("insert into cn_share values (#{shareId},#{shareTittle},#{shareBody},#{noteId})")
    public void addShare(Share share);

    @Select("select * from cn_share where cn_share_title like #{noteTittle}")
    @ResultMap("shareResultMapper")
    public List<Share> getByTittle(@Param("noteTittle")String noteTittle);

    @Select("select * from cn_share where cn_share_id = #{shareId}")
    @ResultMap("shareResultMapper")
    public Share getById(String shareId);
}
